home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / batchut / countdn.zip / COUNTDN.C next >
Text File  |  1988-10-24  |  1KB  |  69 lines

  1. /*
  2.   COUNTDOWN Ver 1.0           This Program is PUBLIC DOMAIN
  3.   Author: Kirby Angell                Do with it what you will
  4.   Date : Oct 88
  5.  
  6.   Commets to the author may be addressed to:
  7.     via NetMail address 147/42
  8.     BBS Number (405)771-5954
  9.     Or by snail at
  10.         12500 Teakwood Rd
  11.         Edmond, OK  73013
  12. */
  13.  
  14. #define LIMIT 30
  15. #define OK 0
  16. #define ERROR 1
  17. #include <stdlib.h>
  18.  
  19. logo()
  20. {
  21.   printf("\nCOUNTDOWN ver 1.0\n");
  22.  
  23. }
  24.  
  25. argcheck(int count, char *param)
  26. {
  27.   if (count < 2) {
  28.     printf("\nUSAGE: COUNTDN 1 50\n");
  29.     printf("Would exit with errorlevel 1 if you press a key before the program ends,\n");
  30.     printf("or exit in 50 seconds with errorlevel %d if you don't.\n",OK);
  31.     exit(ERROR);
  32.   }
  33.   if ((atoi(param) == OK) || (atoi(param) == ERROR)) {
  34.     printf("\nERROR: Errorlevel cannot equal %d or %d\n",OK,ERROR);
  35.     exit(ERROR);
  36.   }
  37. }
  38.  
  39. main(int argc, char *argv[])
  40. {
  41.   int timer;
  42.   int errorlevel;
  43.   int top;
  44.  
  45.   logo();
  46.   argcheck(argc,argv[1]);
  47.  
  48.   errorlevel = atoi(argv[1]);
  49.   if (argc == 3)
  50.     top = atoi(argv[2]);
  51.   else
  52.     top = LIMIT;
  53.  
  54.   printf("Press Any Key to exit with given errorlevel...\n");
  55.  
  56.   for (timer = top;timer > 0; --timer) {
  57.     printf(".");
  58.     delay(1000);
  59.     if (kbhit())
  60.     {
  61.       getch();
  62.       printf("\n");
  63.       exit(errorlevel);
  64.     }
  65.   }
  66.   printf("\n");
  67.   return OK;
  68. }
  69.